package com.example;

import com.example.entity.Payment;
import com.example.service.IPayment;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
// exposeProxy = true 将当前AOP的代理对象暴露出来, proxyTargetClass = true 设置true 是使用 cglib 代理
//@EnableAspectJAutoProxy(exposeProxy = true, proxyTargetClass = true)
//@EnableAspectJAutoProxy(exposeProxy = true)
public class MP_Application {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(MP_Application.class, args);
        IPayment iPayment = run.getBean(IPayment.class);
        Payment payment = new Payment();
        payment.setUserId(1001);
        payment.setName("98K");
        payment.setAmount(300);
        try {
//            同一个类里面掉自己类里面的方法
            iPayment.pay(payment);

//            不管是否购买成功，都要将购买记录成功保存
//            iPayment.payAndRecord(payment);
//            System.out.println("----------------------------------------");
//            payment.setName("3级头");
//            iPayment.payAndRecord(payment);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
